package com.lizhi.note.entity;

import jakarta.persistence.Entity;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

@Entity
@Table(name = "notebook_last_visit",
        uniqueConstraints = {
                @UniqueConstraint(columnNames = "user_id")
        })
@EntityListeners(AuditingEntityListener.class)
@Getter
@Setter
@NoArgsConstructor
@SQLDelete(sql = "UPDATE notebook_last_visit SET deleted = id WHERE id = ?")
@Where(clause = "deleted = 0")
public class NotebookLastVisitEntity extends BaseEntity{
    private Long notebookId;

    private Long userId;

    public NotebookLastVisitEntity(Long notebookId, Long userId) {
        this.notebookId = notebookId;
        this.userId = userId;
    }
}
